package com.foreknow.demo5;

/**
 * 方法与构造器的重载
 */

public class OverLoadDemo {

    private int age;

    public OverLoadDemo() {

    }

    public OverLoadDemo(int age) {
        this.age = age;
    }

    public int add(int a,int b) {
        return a + b;
    }

    public int add(int a,int b,int c) {
        return a + b + c;
    }

    public static void main(String[] args) {
        OverLoadDemo over = new OverLoadDemo();
        int sum = over.add(1,2,3);
        System.out.println(sum);

        int sum1 = over.add(3,4);
        System.out.println(sum1);
    }

}














